import { createRouter, createWebHashHistory } from 'vue-router'

const router = createRouter({
  history: createWebHashHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/profile'
    },
    {
      path: '/profile',
      component: () => import('../views/ProfileView.vue'),
      meta: { title: '个人信息' }
    },
    {
      path: '/edit/name',
      component: () => import('../views/EditName.vue'),
      meta: { title: '编辑昵称' }
    },
    {
      path: '/edit/intro',
      component: () => import('../views/EditIntro.vue'),
      meta: { title: '编辑简介' }
    },
  ],
})

router.afterEach((to) => {
  document.title = to.meta.title as string
})

export default router
